package cool.mtc.minghe.data.model.sys.permission.form;

import cool.mtc.minghe.data.entity.sys.permission.PermissionDO;
import cool.mtc.web.model.form.LongIdFormSupport;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * @author 明河
 */
@Schema(description = "表单")
@Data
public class PermissionForm implements LongIdFormSupport {
    
    @Schema(description = "ID")
    private Long permissionId;

    @Schema(description = "名称")
    private String name;

    @Schema(description = "描述")
    private String description;

    @Schema(description = "权限；格式：模块:实体:操作；例：sys:role:create（创建角色操作）")
    private String permission;

    @Schema(description = "排序")
    private Integer orderIndex;

    @Override
    public Long getId() {
        return permissionId;
    }

    public PermissionDO transToDO() {
        PermissionDO permissionDO = new PermissionDO();
        this.updateDO(permissionDO);
        return permissionDO;
    }

    public void updateDO(PermissionDO permissionDO) {
        BeanUtils.copyProperties(this, permissionDO);
    }
}
